home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / System7 tools / Frontier / Frontier SDK 2.1 / Toolkits / IAC Tools / iacstring.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-09  |  1.6 KB  |  79 lines  |  [TEXT/KAHL]

  1.  
  2. /*© Copyright 1988-1993 UserLand Software, Inc.  All Rights Reserved.*/
  3.  
  4. #include "iacinternal.h"
  5.  
  6.     
  7. Boolean IACpushstringparam (Str255 val, OSType keyword) {
  8.         
  9.     return (IACpushstringitem (IACglobals.event, val, keyword));
  10.     } /*IACpushstringparam*/
  11.  
  12.  
  13. Boolean IACreturnstring (Str255 x) {
  14.     
  15.     return (IACpushstringitem (IACglobals.reply, x, keyDirectObject));
  16.     } /*IACreturnstring*/
  17.  
  18.  
  19. Boolean IACgetstringparam (OSType keyword, Str255 val) {
  20.     
  21.     if (!IACgetstringitem (IACglobals.event, keyword, val)) {
  22.  
  23.         IACparamerror (IACglobals.errorcode, "\pstring", keyword);
  24.         
  25.         return (false);
  26.         }
  27.     
  28.     IACglobals.nextparamoptional = false; /*must be reset for each param*/
  29.     
  30.     return (true);
  31.     } /*IACgetstringparam*/
  32.  
  33.  
  34. Boolean IACgetstringitem (AEDescList *list, long n, Str255 val) {
  35.     
  36.     register OSErr ec;
  37.     DescType key;
  38.     DescType typeCode;
  39.     Size actualSize;
  40.     
  41.     if ((*list).descriptorType != typeAEList) {
  42.     
  43.         ec = AEGetKeyPtr (list, n, typeChar, &typeCode, (Ptr)&val[1], (Size)255, &actualSize);
  44.  
  45.         if (ec != errAEDescNotFound)
  46.             goto finishString;
  47.         }
  48.  
  49.     ec = AEGetNthPtr (list, n, typeChar, &key, &typeCode, (Ptr)&val[1], (Size)255, &actualSize);
  50.  
  51.     finishString:
  52.     
  53.     if (actualSize > 255)
  54.         val[0] = 255;
  55.     else
  56.         val[0] = actualSize;
  57.     
  58.     IACglobals.errorcode = ec;
  59.     
  60.     return (ec == noErr);
  61.     } /*IACgetstringitem*/
  62.  
  63.  
  64. Boolean IACpushstringitem (AEDescList *list, Str255 val, long n) {
  65.     
  66.     register OSErr ec;
  67.     
  68.     if ((*list).descriptorType != typeAEList)
  69.         ec = AEPutKeyPtr (list, n, typeChar, (Ptr)&val[1], (Size)val[0]);
  70.     else
  71.         ec = AEPutPtr (list, n, typeChar, (Ptr)&val[1], (Size)val[0]);
  72.     
  73.     IACglobals.errorcode = ec;
  74.     
  75.     return (ec == noErr);
  76.     } /*IACpushstringitem*/
  77.  
  78.  
  79.